<%--
  Created by IntelliJ IDEA.
  User: 惟手熟尔
  Date: 2023/6/26
  Time: 9:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="zh-CN" class="ax-vertical-centered">
<head>
    <meta charset="UTF-8">
    <title>图书馆管理系统 --图书管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="static/css/bootstrap.min.css">
    <link rel="stylesheet" href="static/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="static/css/bootstrap-admin-theme.css">
    <link rel="stylesheet" href="static/css/bootstrap-admin-theme.css">
    <script src="static/js/bootstrap.min.js"></script>
    <script src="static/jQuery/jquery-3.1.1.min.js"></script>
    <script src="static/js/bootstrap-dropdown.min.js"></script>
    <script src="static/js/adminUpdateInfo.js"></script>
    <script src="static/js/adminUpdatePwd.js"></script>

</head>

<script src="static/js/jquery.min.js"></script>
<script src="static/js/bootstrap.min.js"></script>
<script type="text/javascript">
    function showInfo2(bookId,bookName, bookType, bookCard,bookAuthor, bookPress,  bookNum) {
        document.getElementById("updateBookId").value = bookId;
        document.getElementById("updateBookName").value = bookName;
        document.getElementById("updateBookType").value = bookType;
        document.getElementById("updateBookCard").value = bookCard;
        document.getElementById("updateBookAuthor").value = bookAuthor;
        document.getElementById("updateBookPress").value = bookPress;
        document.getElementById("updateBookNum").value = bookNum;

    }
    function deletebook(bookId) {
        console.log(bookId);
        con = confirm("是否删除?");
        if(con == true) {
            location.href = "DeleteServlet?bookId="+bookId;
        }
    }
</script>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <nav class="navbar navbar-default" role="navigation">
                <div class="navbar-header">
                    <a class="navbar-brand" href="index_admin.jsp"><strong>图书馆管理系统 --管理员页面</strong></a>
                </div>
                <form class="navbar-form navbar-left" role="search">
                    <div class="form-group">
                        <input type="text" class="form-control" />
                    </div> <button type="submit" class="btn btn-default">Submit</button>
                </form>
                <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown"><a href="#" role="button"
                                            class="dropdown-toggle" data-hover="dropdown"> <i
                            class="glyphicon glyphicon-user"></i> ${name1}(${id})
                        <i class="caret"></i></a>
                        <ul class="dropdown-menu">
                            <li><a href="login.jsp">退出</a></li>
                        </ul>
                    </li>
                </ul>
            </nav>
        </div>
    </div>
</div>
<div class="container">
    <!-- left, vertical navbar & content -->
    <div class="row">
        <!-- left, vertical navbar -->
        <div class="col-md-2 bootstrap-admin-col-left">
            <ul class="nav navbar-collapse collapse bootstrap-admin-navbar-side">
                <li><a href="bookDisplayServlet"><i
                        class="glyphicon glyphicon-chevron-right"></i> 图书管理</a></li>
                <li><a href="UserServlet"><i
                        class="glyphicon glyphicon-chevron-right"></i> 用户管理</a></li>
                <li><a href="borrowInfoServlet"><i
                        class="glyphicon glyphicon-chevron-right"></i> 图书借阅管理</a></li>
            </ul><br><br>

            <ul class="nav navbar-collapse collapse bootstrap-admin-navbar-side">
                <li><a href="update_info.jsp"><i
                        class="glyphicon glyphicon-chevron-right"></i> 修改个人信息</a></li>
            </ul>
        </div>

        <!-- content -->
        <div class="col-md-10">
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default bootstrap-admin-no-table-panel">
                        <div class="panel-heading">
                            <div class="text-muted bootstrap-admin-box-title">查询</div>
                        </div>
                        <div class="bootstrap-admin-no-table-panel-content bootstrap-admin-panel-content collapse in">
                            <form class="form-horizontal" action="SelectBookServlet"
                                  method="post">
                                <!-- <input type="hidden" name="tip" value="1"> -->
                                <input type="hidden" name="tip" value="1">
                                <div class="col-lg-7 form-group">
                                    <label class="col-lg-4 control-label" >图书信息</label>
                                    <div class="col-lg-8">
                                        <input class="form-control" id="bookName" name="name"
                                               type="text" value=""> <label class="control-label"
                                                                            style="display: none;"></label>
                                    </div>
                                </div>
                                <div class="col-lg-3 form-group">

                                    <button type="submit" class="btn btn-primary" id="btn_query">查询</button>
                                </div>
                                <div class="col-lg-3 form-group">
                                    <button type="button" class="btn btn-primary" id="btn_add"
                                            data-toggle="modal" data-target="#addModal">添加图书</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-lg-12">
                    <table id="data_list" class="table table-hover table-bordered"
                           cellspacing="0" width="100%">
                        <thead>
                        <tr>
                            <th>图书序号</th>
                            <th>图书名称</th>
                            <th>图书类型</th>
                            <th>图书编号</th>
                            <th>作者名称</th>
                            <th>图书出版社</th>
                            <th>总数</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        <c:forEach var="book" items="${list1}" varStatus="vs">
                            <tr <c:if test="${vs.count%2==0}">class="success"</c:if> >
                                <td>${book.bookId}</td>
                                <td>${book.bookName}</td>
                                <td>${book.bookType}</td>
                                <td>${book.bookCard}</td>
                                <td>${book.bookAuthor}</td>
                                <td>${book.bookPress}</td>
                                <td>${book.bookNum}</td>
                                <td>
                                    <button type="button" class="btn btn-warning btn-xs"
                                    data-toggle="modal" data-target="#updateModal" id="btn_update"
                                    onclick="showInfo2('${book.bookId}','${book.bookName}','${book.bookType}',
                                            '${book.bookCard}','${book.bookAuthor}','${book.bookPress}',
                                            '${book.bookNum}')">修改</button>
                                    <button type="button" class="btn btn-danger btn-xs" onclick="deletebook(${book.bookId})">删除</button>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<form class="form-horizontal" method="post" action="ModifyServlet">
    <div class="modal fade" id="updateModal" tabindex="-1" role="dialog"
         aria-labelledby="updateModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"
                            aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="updateModalLabel">修改图书信息</h4>
                </div>
                <div class="modal-body">

                    <!---------------------表单-------------------->

                    <div class="form-group">
                        <label class="col-sm-3 control-label">图书号</label>
                        <div class="col-sm-7">
                            <input type="hidden" id="updateBookId" name="bookId">
                            <input type="text" class="form-control" id="updateBookCard"
                                   name="bookCard" placeholder="请输入书号"> <label
                                class="control-label" for="updateBookCard" style="display: none;"></label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">图书名称</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="updateBookName"
                                   name="bookName" placeholder="请输入图书名称"> <label
                                class="control-label" for="updateBookName"
                                style="display: none;"></label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">图书类型</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="updateBookType"
                                   name="bookType" placeholder="请输入图书类型"> <label
                                class="control-label" for="updateBookName"
                                style="display: none;"></label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">作者名称</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="updateBookAuthor"
                                   name="bookAuthor" placeholder="请输入作者名称"> <label
                                class="control-label" for="updateBookAuthor" style="display: none;"></label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">出版社</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="updateBookPress"
                                   name="bookPress" placeholder="请输入出版社"> <label
                                class="control-label" for="updateBookPress" style="display: none;"></label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">总数量</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="updateBookNum"
                                   name="bookNum" placeholder="请输入总数量"> <label
                                class="control-label" for="updateBookNum" style="display: none;"></label>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">修改</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal -->
    </div>
</form>

<!----------添加------->
<form class="form-horizontal" method="post" action="AddBookServlet">
    <div class="modal fade" id="addModal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"
                            aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">添加新图书</h4>
                </div>
                <div class="modal-body">

                    <div class="form-group">
                        <label class="col-sm-3 control-label">图书号</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="addISBN"
                                   required="required" name="bookCard" placeholder="请输入书号"> <label
                                class="control-label" for="addISBN" style="display: none;"></label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">图书名称</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="addBookName"
                                   required="required" name="bookName" placeholder="请输入图书名称">
                            <label class="control-label" for="addBookName"
                                   style="display: none;"></label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">图书类型</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="addBookType"
                                   name="bookType" placeholder="请输入图书类型"> <label
                                class="control-label" for="updateBookName"
                                style="display: none;"></label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">作者名称</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="addAutho"
                                   required="required" name="bookAuthor" placeholder="请输入作者名称">
                            <label class="control-label" for="addAutho"
                                   style="display: none;"></label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">出版社</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="addPress"
                                   required="required" name="bookPress" placeholder="请输入出版社">
                            <label class="control-label" for="addPress"
                                   style="display: none;"></label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">总数量</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" id="addNum"
                                   required="required" name="bookNum" placeholder="请输入图书总数量">
                            <label class="control-label" for="addNum" style="display: none;"></label>
                        </div>
                    </div>

                    <!---------------------表单-------------------->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">添加</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal -->
    </div>
</form>
</body>
</html>
